package com.sdy.common.utils;

public class OsPathUtil {
    public static String convertToUnix(String path) {
        if (StringUtil.isBlank(path)) {
            return path;
        }
        if (path.startsWith("c:/") || path.startsWith("C:/")) {
            path = path.substring(2);
        }
        return path;
    }

    public static String convertToWindows(String path) {
        if (StringUtil.isBlank(path)) {
            return path;
        }
        if (!(path.startsWith("c:/") || path.startsWith("C:/"))) {
            path = "C:".concat(path);
        }
        return path;
    }
    
    public static String convertWithOs(String path) {
        if (StringUtil.isBlank(path)) {
            return path;
        }
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {
            return convertToWindows(path);
        } else {
            return convertToUnix(path);
        }
    }
}
